<template>
  <createNavBar></createNavBar>
  <van-address-edit
    :area-list="areaList"
    show-search-result
    :area-columns-placeholder="['请选择', '请选择', '请选择']"
    @save="onSave"
  />
</template>

<script setup>
import request from "../utils/request.js";
import { areaList } from "@vant/area-data";
import { useRouter } from "vue-router";
import createNavBar from "@/components/createNavBar.vue";
const userId = localStorage.getItem("userId");
const router = useRouter();
// 发送一个创建地址的请求 onSave方法接收一个content作为参数
const onSave = async (content) => {
  const result = await request.post("/api/v1/addAddress/" + userId, {
    real_name: content.name,
    mobile: content.tel,
    city: content.province + content.city + content.county,
    area: content.areaCode,
    house: content.addressDetail,
  });
  history.back();
};
</script>

<style lang="scss" scoped></style>
